home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / jabber / JabberResource.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  5KB  |  139 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from contacts.BuddyListElement import BuddyListElement
  5. from common.Buddy import fileinfo
  6. from util import strip_html, Storage
  7. import common
  8. import jabber
  9. from common.actions import action
  10. from common.Buddy import get_status_orb
  11. GTALK = 'gtalk'
  12. JABBER = 'jabber'
  13. statuses = Storage(dnd = _('Do Not Disturb'), chat = _('Free for Chat'), xa = _('Extended Away'))
  14.  
  15. class JabberResource(BuddyListElement):
  16.     __metaclass__ = common.ActionMeta
  17.     
  18.     def __init__(self, jabber, jid, presence):
  19.         self.jid = jid
  20.         self._set_presence(presence)
  21.         self.name = self.jid.as_unicode()
  22.         self.alias = self.name
  23.         self.protocol = jabber
  24.         self.sms = False
  25.  
  26.     
  27.     def sort(self, *a, **k):
  28.         pass
  29.  
  30.     
  31.     def _set_presence(self, presence):
  32.         self.status_msg = presence.get_status()
  33.         self.show = presence.get_show()
  34.         self.priority = presence.get_priority()
  35.  
  36.     
  37.     def get_status_message(self):
  38.         return self.status_msg
  39.  
  40.     
  41.     def set_status_message(self, val):
  42.         self.status_msg = val
  43.  
  44.     status_message = property(get_status_message, set_status_message)
  45.     
  46.     def stripped_msg(self):
  47.         msg = self.status_message
  48.         return None if msg else u''
  49.  
  50.     stripped_msg = property(stripped_msg)
  51.     
  52.     def service(self):
  53.         if self.jid.domain == 'gmail.com':
  54.             return GTALK
  55.         else:
  56.             return JABBER
  57.  
  58.     service = property(service)
  59.     
  60.     def away(self):
  61.         if self.service == GTALK:
  62.             if not (self.available):
  63.                 pass
  64.             return not (self.idle)
  65.         else:
  66.             return not (self.available)
  67.  
  68.     away = property(away)
  69.     
  70.     def available(self):
  71.         return self.show in jabber.available_show_types
  72.  
  73.     available = property(available)
  74.     
  75.     def idle(self):
  76.         if self.service == GTALK:
  77.             return self.show == 'away'
  78.         else:
  79.             return False
  80.  
  81.     idle = property(idle)
  82.     
  83.     def mobile(self):
  84.         return False
  85.  
  86.     mobile = property(mobile)
  87.     
  88.     def icon(self):
  89.         return False
  90.  
  91.     icon = property(icon)
  92.     
  93.     def pending_auth(self):
  94.         return False
  95.  
  96.     pending_auth = property(pending_auth)
  97.     
  98.     def online(self):
  99.         return True
  100.  
  101.     online = property(online)
  102.     
  103.     def blocked(self):
  104.         return False
  105.  
  106.     blocked = property(blocked)
  107.     
  108.     def long_show(self):
  109.         pass
  110.  
  111.     long_show = property(long_show)
  112.     status_orb = property((lambda self: get_status_orb(self)))
  113.     
  114.     def sightly_status(self):
  115.         status = self.show
  116.         if status:
  117.             return statuses.get(status, status.title())
  118.         else:
  119.             return _('Available')
  120.  
  121.     sightly_status = property(sightly_status)
  122.     
  123.     def __repr__(self):
  124.         return '<JabberResource %s>' % self.jid.as_unicode()
  125.  
  126.     
  127.     def send_file(self, filepath = None):
  128.         if filepath is None:
  129.             Hub = Hub
  130.             import hub
  131.             filepath = Hub.getInstance().get_file('Sending file to %s' % self.name)
  132.         
  133.         if filepath:
  134.             self.protocol.send_file(self, fileinfo(filepath))
  135.         
  136.  
  137.     send_file = action()(send_file)
  138.  
  139.